<?php 
	include_once 'ErrorHandler.php';
	include_once 'DBConsts.php';
?>
<?php
class DataProvider
{
	public static function Query($sql)
	{
		$connection = DataProvider::Open();
		mysqli_query($connection,"SET character_set_results=utf8");
		if (!($result = @mysqli_query($connection,$sql)))
			ErrorHandler::showError();
		DataProvider::Close($connection);
		return $result;
	}	
	
	public static function Open ()
	{
		$connection = mysqli_connect(DBConsts::$HOSTNAME,DBConsts::$USERNAME,DBConsts::$PASSWORD,DBConsts::$DATABASENAME) or die("Some error occurred during connection " . mysqli_error($con));
		return $connection;
	}
	
	public static function MoreQuery ($sql, $connection)
	{
		mysqli_query($connection,"SET character_set_results=utf8");
		if (!($result = @mysqli_query($connection,$sql)))
			ErrorHandler::showError();
		return $result;
	}
	
	public static function Close($connection)
	{
		if (!(mysqli_close($connection)))
			ErrorHandler::showError();
	}
	
	
}
?>